﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Tabs（懒加载）</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" /><link href="../demo.css" rel="stylesheet" type="text/css" />

    <script src="../../scripts/jquery-1.6.2.min.js" type="text/javascript"></script>
    <script src="../../scripts/miniui/miniui.js" type="text/javascript"></script><link href="../../scripts/miniui/themes/default/miniui.css" rel="stylesheet" type="text/css" />
    <link href="../../scripts/miniui/themes/icons.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    html, html body
    {
        padding:0;border:0;margin:0;
        width:100%;height:100%;overflow:hidden;
        font-family:Verdana;
        font-size:12px;    
        line-height:22px;
    }        
    .header
    {
        background:url(../header.gif) repeat-x 0 -1px;
    }
    </style>
</head>
<body>
<div  id="vForm" class="mini-layout" style="width: 100%; height: 100%;">
    <div class="header1" region="north" height="100" showsplit="true" splitSize="0" showheader="false"bodystyle="overflow:hidden;">
        <div style="padding-left:30px;">
            <div class="Title" style="height:35px; line-height:35px;">生产计划单</div>
        </div>
    <table cellpadding="0" cellspacing="0" width="100%" style=" border:1px solid #4695c3;">
        <tr>
            <td style="padding-left:10px; height:25px;">
                <table>
                    <tr>
                        <td style="width:60px; text-align:center;">来往单位</td>
                        <td style="width:120px;"><input id="Did" name="Did" class="mini-buttonedit" style="width: 100%" onbuttonclick="onButtomselectComplany" required="true"/></td>
                        <td style="width:60px; text-align:center;">投产日期</td>
                        <td style="width:120px;"><input id="StartTime" name="StartTime" class="mini-datepicker" value="" /></td>
                        <td style="width:60px; text-align:center;">交货日期</td>
                        <td style="width:120px;"><input id="EndTime" name="EndTime" class="mini-datepicker" value="" /></td>
                    </tr>
                    <tr>
                        <td style="width:60px; text-align:center;">设备名称</td>
                        <td style="width:120px;"><input id="EquipmentID" name="EquipmentID" class="mini-textbox" style="width: 100%" required="true" onbuttonclick="onButtomselectComplany"/></td>
                        <td style="text-align:center;">备注</td>
                        <td colspan="3" style="width:300px;"><input class="mini-textbox" name="Remark" value="" style="width: 100%;" /></td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    </div>
    <div title="south" region="south" showSplit="false" showHeader="false" height="50" style="border:0px;">
        <table cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td style="width:80%; text-align:left;">
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <td style="padding-left:30px; height:20px; width:70px;">
                                制单员:
                            </td>
                            <td style="height:20px;">
                              <input class="mini-textbox" value="" name="PlanMan" />
                            </td>
                            <td style="padding-left:30px; height:20px; width:50px;">
                                审核人:
                            </td>
                            <td style="height:20px;">
                              <input class="mini-textbox" value="" name="AuditMan" />
                            </td>
                            <td style="padding-left:30px; height:20px; width:70px;">
                                制单日期:
                            </td>
                            <td style="height:20px;">
                              <input id="Created" name="Created" class="mini-datepicker" value="" />
                            </td>
                        </tr>
                    </table>
                </td>
                <td style="width:20%;">
                    <div style="text-align:right;">   
                        <a class="mini-button" onclick="test">打印</a>   
                        <a class="mini-button" onclick="onAdd">保存</a>       
                        <a class="mini-button" onclick="onCancel">退出</a>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <div title="center" region="center" bodystyle="overflow:hidden;" style="padding:3px; border:1px solid #4695c3; background-color:rgb(217, 243, 255);">
        <div id="datagrid1" class="mini-datagrid" style="width: 100%; height: 100%;" url="" idField="ID" pageSize="20" showFooter="false" onselectionchanged="onSelectionChanged">
            <div property="columns">
                <div type="indexcolumn"></div>
                <div name="productcolumn" field="ProductID" width="100" headeralign="center">商品编码</div>
                <div field="FullName" name="fullname" width="150" headeralign="center">商品全名
                     <input property="editor" class="mini-buttonedit" onbuttonclick="onButtonProduct" style="width:100%;"/>
                </div>
                <div field="Models" name="modelsname" width="100" headeralign="center">商品型号
                    <input property="editor" class="mini-textbox" style="width:100%;"/>
                </div>
                <div field="Unit" name="unitname" width="100" headeralign="center">商品单位
                    <input property="editor" class="mini-textbox" style="width:100%;"/>
                </div>
                <div field="Number" name="numbername" width="120" headeralign="center">投产数量
                    <input property="editor" class="mini-spinner" valuechanged="CalculationAmount" maxValue="100000" style="width:100%;"/>
                </div>
                <div field="Remark" name="remarkname" width="100%" headeralign="left">生产备注
                    <input property="editor" class="mini-textbox" style="width:100%;"/>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    mini.parse();
    var grid = mini.get("datagrid1");
    grid.hideColumn("productcolumn");

    newRow();
    function newRow() {
        for (i = 0; i < 20; i++) {
            var row = {};
            grid.addRow(row);
        }
    }

    function onSelectionChanged(e) {
        UpdateRows();
        var Lastrow = grid.getSelected();
        grid.beginEditRow(Lastrow);
    }

    function onAdd() {
    debugger
        var form = new mini.Form("#vForm");
//        form.validate();
//        if (form.isValid() == false) return;
        var data = form.getData(), json = mini.encode(data);
        var item = grid.getEditData(true);
        itemjson = mini.encode(item);
        $.ajax({ url: "/Production/PlanBiLL", data: { data: json, item: itemjson }, cache: false,
            type: "post",
            success: function (text) { mini.alert(text.error); /*CloseWindow("save"); */ },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(jqXHR.responseText);
                CloseWindow();
            }
        });
    }

    function UpdateRows() {
        var row = grid.getEditData(true)
        for (var o = 0; o < row.length; o++) {
            var json = mini.encode(row[o]);
            grid.updateRow(row[o], json);
        }
    }
</script>

</body>
</html>